package com.ruoyi.hr.controller.hr.entryexitmanage;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.Ztree;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.hr.service.entryexitmanage.EntryExitManageService;
import com.ruoyi.hr.service.salaryadmin.SalaryAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author zeo
 * @explain 入离职管理
 * @date 2020/2/27
 */
@Controller
@RequestMapping("/entryExitManage")
public class EntryExitManageController extends BaseController {

    @Autowired
    EntryExitManageService entryExitManageService;

    private String prefix = "hr/entryexitmanage";

    /**
     * 跳转分页页面
     */
    @GetMapping()
    public String entryExitManage() {
        return prefix + "/entryExitManage";
    }

    /**
     * 欢迎
     */
    @GetMapping("/welcome")
    public String welcome() {
        return prefix + "/welcome";
    }

    /**
     * 加载薪资管理左侧树状
     */
    @GetMapping("/treeData")
    @ResponseBody
    public List<Ztree> treeData() {
        List<Ztree> ztrees = new ArrayList<Ztree>();
        Ztree ztree[] = {
                new Ztree((long) 100, (long) 0, "入职管理", "入职管理"),
                new Ztree((long) 101, (long) 100, "新员工入职登记", "新员工入职登记"),
                new Ztree((long) 102, (long) 100, "入职历史查询", "入职历史查询"),

                new Ztree((long) 103, (long) 0, "复职管理", "复职管理"),
                new Ztree((long) 104, (long) 103, "老员工复职登记", "老员工复职登记"),
                new Ztree((long) 105, (long) 103, "复职历史查询", "复职历史查询"),

                new Ztree((long) 116, (long) 0, "离职管理", "离职管理"),
                new Ztree((long) 117, (long) 116, "员工离职登记", "员工离职登记"),
                new Ztree((long) 118, (long) 116, "员工离职历史", "员工离职历史"),

                new Ztree((long) 119, (long) 0, "退休管理", "退休管理"),
                new Ztree((long) 120, (long) 119, "员工退休登记", "员工退休登记"),
                new Ztree((long) 121, (long) 119, "员工退休历史", "员工退休历史"),

                new Ztree((long) 122, (long) 0, "黑名单管理", "黑名单管理"),
                new Ztree((long) 123, (long) 122, "黑名单登记", "黑名单登记"),
                new Ztree((long) 124, (long) 122, "黑名单管理历史", "黑名单管理历史"),

        };
        for (int i = 0; i < ztree.length; i++) {
            ztrees.add(ztree[i]);
        }
        return ztrees;
    }

    @RequestMapping("/getEmpList")
    @ResponseBody
    public TableDataInfo getEmpList(@RequestParam Map map){
        startPage();
        List<Map<String,Object>> list = entryExitManageService.getEmpList(map);
        return getDataTable(list);
    }

}
